package com.mapapp.flutter_mapapp.adapter;

import android.graphics.Color;
import android.support.annotation.NonNull;
import android.widget.ImageView;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.mapapp.flutter_mapapp.R;
import com.mapapp.flutter_mapapp.bean.OperationBean;

public class HistoryAdapter extends BaseQuickAdapter<OperationBean, BaseViewHolder> {
    public HistoryAdapter(int layoutResId) {
        super(layoutResId);
    }

    @Override
    protected void convert(@NonNull BaseViewHolder helper, OperationBean item) {

        TextView tvStatus = helper.getView(R.id.tv_status);
        TextView tvProcess = helper.getView(R.id.tv_process);
        TextView tvName = helper.getView(R.id.tv_name);
        TextView tvTime = helper.getView(R.id.tv_time);
        ImageView progressStep = helper.getView(R.id.progress_bar);

        tvProcess.setText(item.getProcessName());
        tvName.setText(item.getOperateUserName());
        tvTime.setText(item.getCreateTime());


        int i = item.getProcessOrder();

        switch (i) {
            case 0:
                progressStep.setBackgroundResource(R.drawable.btn_new_data_step1);
                break;
            case 1:
                progressStep.setBackgroundResource(R.drawable.btn_new_data_step2);
                break;
            case 2:
                progressStep.setBackgroundResource(R.drawable.btn_new_data_step3);
                break;
            case 3:
                progressStep.setBackgroundResource(R.drawable.btn_new_data_step4);
                break;
            case 4:
                progressStep.setBackgroundResource(R.drawable.btn_new_data_step5);
                break;
        }

        switch (item.getState()) {
            case 1:
                tvStatus.setText("已完成");
                tvStatus.setTextColor(Color.parseColor("#3E3E3E"));
                break;
            case -1:
                tvStatus.setTextColor(Color.parseColor("#CCCCCC"));
                tvStatus.setText("未完成");
                break;
        }
    }
}
